<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib/tree" prefix="tree"%>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<style type="text/css">
    li{
        padding-top:8px;
    }
</style>
<form name="addCancelDataForm" id="addCancelResonForm" method="post" action="${ctx}/business/projectmanage/saveCancel" >
    <input type="hidden" name="projectId" value="${projectId}"/>
    <input type="hidden" name="status" value="${status}"/>
    <input type="hidden" name="type" value="${type}"/>
    <!-- 	<input type="hidden" name="budgetMenuData" id="budgetMenuData" value=""/> -->
    <table class="infoTable">
        <tbody>
        <tr>
            <th align="right" width="15%">填写原因</th>
            <td  width="36%">
                <textarea id="cancelReason" data-options="required:true" name="cancelReason" style="width:480px;" rows="6" type="text" maxlength="200" value=""></textarea>
            </td>
        </tr>
        <!--  	<tr>
			<th align="right" width="15%">附件</th>
			<td style="border-right: none" width="35%">
				<div id="fileQueue" style="margin: 10px 0px 0px 10px">
					<input type="file" name="uploadify" id="uploadify" data-options="required:true"/>
					<p style="color: #aaaaaa;width: auto">
		1、按住Ctrl可选择多个文件上传;<br/>
		2、可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
		</p>
				</div>
			</td>
			<td style="border-left: none" colspan="2">
				<c:forEach items="${resList}" var="res">
					<c:if test="${res.functionFlog==4}">
						<div><a class="easyui-linkbutton" href="${ctx}/business/projectmanage/fileView?resId=${res.id}" >${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
					</c:if>
				</c:forEach>
			</td>
		</tr>-->
        </tbody>
    </table>
</form>

<script type="text/javascript">
    $(function(){
        parent.$('#addEntityBt').hide();
        var resIds = "";
        <c:forEach items="${resList}" var="res">
        resIds += ",${res.id}";
        </c:forEach>
        $('#budgetMenuData').val(resIds);
        $("#uploadify").uploadify({
            'height'        : 27,
            'width'         : 80,
            'buttonText'    : '选择附件',
            'queueID': 'fileQueue',//队列的ID
            'queueSizeLimit':5,// 附件附列长度
            'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
            'uploader':'${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}',// 上传时请求的后台处理的controller
            'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
            'method':'post',
            'folder': '',
            'preventCaching' : true,
            'fileTypeExts' :'*.jpg;*.png;*.gif;*.bmp;*.pdf;*.zip;*.rar;',
            'auto': true,
            'multi': true,//是否可多选
            'removeCompleted' : false,
            'successTimeout' : 55555,
            'onUploadSuccess':function(file, data, response){
                $('#' + file.id).find('.data').html(' 上传完毕');
                $('#budgetMenuData').val($('#budgetMenuData').val() + "," + data);
                var cancel=$('#fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
                if (cancel) {
                    cancel.attr("rel", data);
                    cancel.click(function () {
                        var cancelData = cancel.attr("rel");
                        var  budgetMenuData = $('#budgetMenuData').val();
                        var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
                        if(index != -1){
                            budgetMenuData = budgetMenuData.replace(","+cancelData,"");
                            $('#budgetMenuData').val(budgetMenuData);
                        }
                    });
                }
            },
            'onSelectError':function(file, errorCode, errorMsg){
                switch(errorCode) {
                    case -110:
                        //this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
                        this.queueData.errorMsg='所选文件大小超出系统限制!';
                        break;
                    case -120:
                        //this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
                        this.queueData.errorMsg='所选文件大小异常!';
                        break;
                    case -130:
                        //this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
                        this.queueData.errorMsg='所选文件类型不正确!';
                        break;
                }
            },
            'onCancel' : function(file){
                alert(file);
            }
        });
    });
    function deleteFile(v,resId){
        var parent = v.parentNode;
        parent.parentNode.removeChild(parent);
        var  budgetMenuData = $('#budgetMenuData').val();
        var index = budgetMenuData.indexOf(","+resId)
        if(index != -1){
            budgetMenuData = budgetMenuData.replace(","+resId,"");
            $('#budgetMenuData').val(budgetMenuData);
        }
    }

</script>
		